version: "3.9"

networks:
  postgres:
    driver: bridge
  webapi:
    driver: bridge

services:

  app:
    container_name: web-api-app
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "80:80"
    links:
      - postgres 
    networks:
      - webapi
    depends_on:
      - postgres

  postgres:
    container_name: postgres_db
    image: postgres
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-admin}
      PGDATA: /data/postgres
    volumes:
       - postgres:/data/postgres
    ports:
      - "5432:5432"
    networks:
      - postgres
      - webapi
    restart: unless-stopped
  
  pgadmin:
    container_name: pgadmin_db
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
      PGADMIN_CONFIG_SERVER_MODE: 'False'
    volumes:
       - pgadmin:/var/lib/pgadmin

    ports:
      - "${PGADMIN_PORT:-5050}:80"
    networks:
      - postgres
    restart: unless-stopped
    depends_on:
      - postgres
        
volumes:
    postgres:
    pgadmin: